package com.hotel.dao.impl;

import com.hotel.dao.OrderDao;
import com.hotel.utils.JdbcUtils;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.util.List;
import java.util.Map;

/**
 * 订单模块dao开发
 * Created by LinYaTing on 2018/11/28 0:37
 */
public class OrderDaoImpl implements OrderDao {

    @Override
    public List<Map<String, Object>> findAll() {
        String sql = "SELECT  o.id,dt.id tableId,dt.tableName,o.orderDate,o.totalPrice,o.orderStatus FROM orders o INNER JOIN dinnertable dt ON o.table_id=dt.id ";
        try {
            return JdbcUtils.getQueryRunner().query(sql, new MapListHandler());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
